package com.hzit.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;

import lombok.*;

/**
 * <p>
 * 
 * </p>
 *
 * @author wf
 * @since 2023-12-28
 */
@Data
@TableName("student1")
@AllArgsConstructor
@NoArgsConstructor
public class Student implements Serializable {

    private static final long serialVersionUID = 1L;

    // 使用分布式id生成器（雪花算法生成器）生成id
    @TableId(value = "sid", type = IdType.ASSIGN_ID)
    private Long sid;

    private String sname;

    private String sex;

    private Integer age;

    private String addr;

    private Integer cid;

    private LocalDate birth;

    // 配置逻辑删除字段，默认逻辑删除字段为1，逻辑不删除字段值为0
    @TableLogic
    private Integer deleted;

    @TableField(fill = FieldFill.INSERT)             // 代表仅在插入操作时为此字段赋值
    private LocalDateTime createTime;


    @TableField(fill = FieldFill.INSERT_UPDATE)     // 代表仅在插入操作和修改操作时为字段赋值
    private LocalDateTime updateTime;

    // 配置乐观锁对应的版本号字段
    @Version
    private Integer version;

    public Student(String sname, String sex, Integer age, String addr, Integer cid) {
        this.sname = sname;
        this.sex = sex;
        this.age = age;
        this.addr = addr;
        this.cid = cid;
    }
}
